<template>
  <div>
    <q-btn
      :label="button"
      @click="confirm(button)"
      style="color: #fff; background-color: #dbb22e; height: 30px; width: 70px; font-size: 10px"
    />
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue';
import { api } from 'src/boot/api';
import { emitter } from 'src/emitter';

export default defineComponent({
  name: 'confirm-button',

  setup(props) {
    const button = ref();
    if (props.params.data.isNeedConfirm == true && props.params.data.confirmUser == null) {
      button.value = '确认';
    } else {
      button.value = '无需确认';
    }
    const confirm = val => {
      if (val == '确认') {
        api.post('/alarmService/confirmAlarmInfo', { id: props.params.data.id, confirmUser: 'admin' }).then(res => {
          if (res.data.code == 200) {
            emitter.emit('renew', { id: '1' });
          }
        });
      } else {
      }
    };
    return { button, confirm };
  },
});
</script>
